
package com.rt.schedulenew.utils.coder;

public final class DefaultSecurityCoderUtil
{
    public static final String encryptRSAByIn(final String data) {
        try {
            final String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIVwAZ2E+O7qVmGPrBrVFVfe93V1bkLrV9LTbEA0tqPLgZzg/BPYQs0j02LZZ9+E6Zdj77iw1i37t6mNx5Xih4ECAwEAAQ==";
            return SecurityCoderUtil.encryptRSAPublic(data, publicKey);
        }
        catch (Exception e) {
            throw new RuntimeException("加密错误，错误信息：", e);
        }
    }
    
    public static final String encryptRSAByOut(final String data) {
        try {
            final String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAI6EufFxlNaT/khIiT8XvbYzYkxN6K26+SNnx7VqeuKeV7GteGMOWqaiGgTS+qLewfhTAje+deL0IXRTrPpCrykCAwEAAQ==";
            return SecurityCoderUtil.encryptRSAPublic(data, publicKey);
        }
        catch (Exception e) {
            throw new RuntimeException("加密错误，错误信息：", e);
        }
    }
    
    public static final String decryptRSAByIn(final String cryptData) {
        try {
            final String privateKey = "MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAhXABnYT47upWYY+sGtUVV973dXVuQutX0tNsQDS2o8uBnOD8E9hCzSPTYtln34Tpl2PvuLDWLfu3qY3HleKHgQIDAQABAkBxOkD0pBAD069m694TirqorJd5ASOF/2Ovjx3tQY21YFEQL3vZma3A6pMwZrb37YSUuw42n7B81DxHQX+KIRDdAiEAxToZjEVuGCT6GgB9mE3OnBlb95NIHasWbx53QbjnqdsCIQCtM5ZG3PyV5SSN1grsNDqAP5G2cqLhMZ6ClwoZaJ8Y0wIhAI2CzXfvDTp3tZfYiEUydq9cJrexzomzC0q5cloOwPIHAiBlvs9B06Gh4JknpRyHg2r2WeGcXx1l0sM+DcJGCNqlNwIhALRnIYsWwtzVldRadRhlQ0MkznGR90KksfI5RRkVS+Yw";
            return SecurityCoderUtil.decryptRSAPrivate(cryptData, privateKey);
        }
        catch (Exception e) {
            throw new RuntimeException("解密错误，错误信息：", e);
        }
    }
    
    public static final String decryptRSAByOut(final String cryptData) {
        try {
            final String privateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAjoS58XGU1pP+SEiJPxe9tjNiTE3orbr5I2fHtWp64p5Xsa14Yw5apqIaBNL6ot7B+FMCN7514vQhdFOs+kKvKQIDAQABAkB08eJmhc4dGYlRpPvB4uhQJu/lLxTb4g3niJQugDZf11aF2R7pBEl3zPDkXbw9KE+DbvIA5U0IkzRpZg46nIAFAiEAy1WTzlY3qxrr+ioeQneFMQW6rJQ6VqRYdelJ5JpKttMCIQCzbqc5tD3sFVUm3DPVXsE68B4SNCPt0puW1481foz8kwIgI1HiMt1XHim3A+V9DB6mzDUqj//Pgm1Z0GGNrGAAynECIGqtuxZ/puEZvcqg2OBeuZuE7xv7i/D1ajPAbRBs8P2pAiEAwAzXmWWOiQVU7YRx5xF+efmysrui5V9Unn8WT9rKX/A=";
            return SecurityCoderUtil.decryptRSAPrivate(cryptData, privateKey);
        }
        catch (Exception e) {
            throw new RuntimeException("解密错误，错误信息：", e);
        }
    }
    
    public static final String decryptDataByIn(final String cryptData, final String encryptAesKey) {
        try {
            final String privateKey = "MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAhXABnYT47upWYY+sGtUVV973dXVuQutX0tNsQDS2o8uBnOD8E9hCzSPTYtln34Tpl2PvuLDWLfu3qY3HleKHgQIDAQABAkBxOkD0pBAD069m694TirqorJd5ASOF/2Ovjx3tQY21YFEQL3vZma3A6pMwZrb37YSUuw42n7B81DxHQX+KIRDdAiEAxToZjEVuGCT6GgB9mE3OnBlb95NIHasWbx53QbjnqdsCIQCtM5ZG3PyV5SSN1grsNDqAP5G2cqLhMZ6ClwoZaJ8Y0wIhAI2CzXfvDTp3tZfYiEUydq9cJrexzomzC0q5cloOwPIHAiBlvs9B06Gh4JknpRyHg2r2WeGcXx1l0sM+DcJGCNqlNwIhALRnIYsWwtzVldRadRhlQ0MkznGR90KksfI5RRkVS+Yw";
            final String decryptAesKey = SecurityCoderUtil.decryptRSAPrivate(encryptAesKey, privateKey);
            return SecurityCoderUtil.decryptAES(cryptData, decryptAesKey);
        }
        catch (Exception e) {
            throw new RuntimeException("解密错误，错误信息：", e);
        }
    }
    
    public static final String decryptDataByOut(final String cryptData, final String encryptAesKey) {
        try {
            final String privateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAjoS58XGU1pP+SEiJPxe9tjNiTE3orbr5I2fHtWp64p5Xsa14Yw5apqIaBNL6ot7B+FMCN7514vQhdFOs+kKvKQIDAQABAkB08eJmhc4dGYlRpPvB4uhQJu/lLxTb4g3niJQugDZf11aF2R7pBEl3zPDkXbw9KE+DbvIA5U0IkzRpZg46nIAFAiEAy1WTzlY3qxrr+ioeQneFMQW6rJQ6VqRYdelJ5JpKttMCIQCzbqc5tD3sFVUm3DPVXsE68B4SNCPt0puW1481foz8kwIgI1HiMt1XHim3A+V9DB6mzDUqj//Pgm1Z0GGNrGAAynECIGqtuxZ/puEZvcqg2OBeuZuE7xv7i/D1ajPAbRBs8P2pAiEAwAzXmWWOiQVU7YRx5xF+efmysrui5V9Unn8WT9rKX/A=";
            final String decryptAesKey = SecurityCoderUtil.decryptRSAPrivate(encryptAesKey, privateKey);
            return SecurityCoderUtil.decryptAES(cryptData, decryptAesKey);
        }
        catch (Exception e) {
            throw new RuntimeException("解密错误，错误信息：", e);
        }
    }
    
    public static final String encryptAES(final String data) {
        try {
            final String password = "h3arlqJktSPzDn7S";
            return AESCoder.encryptByCBC(data, password);
        }
        catch (Exception e) {
            throw new RuntimeException("加密错误，错误信息：", e);
        }
    }
    
    public static final String decryptAES(final String data) {
        try {
            final String aesKey = "h3arlqJktSPzDn7S";
            return AESCoder.decryptByCBC(data, aesKey);
        }
        catch (Exception e) {
            throw new RuntimeException("解密错误，错误信息：", e);
        }
    }
    
    public static final String encryptRSA(final String data) {
        try {
            final String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIVwAZ2E+O7qVmGPrBrVFVfe93V1bkLrV9LTbEA0tqPLgZzg/BPYQs0j02LZZ9+E6Zdj77iw1i37t6mNx5Xih4ECAwEAAQ==";
            return SecurityCoderUtil.encryptRSAPublic(data, publicKey);
        }
        catch (Exception e) {
            throw new RuntimeException("加密错误，错误信息：", e);
        }
    }
    
    public static final String decryptRSA(final String cryptData) {
        try {
            final String privateKey = "MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAhXABnYT47upWYY+sGtUVV973dXVuQutX0tNsQDS2o8uBnOD8E9hCzSPTYtln34Tpl2PvuLDWLfu3qY3HleKHgQIDAQABAkBxOkD0pBAD069m694TirqorJd5ASOF/2Ovjx3tQY21YFEQL3vZma3A6pMwZrb37YSUuw42n7B81DxHQX+KIRDdAiEAxToZjEVuGCT6GgB9mE3OnBlb95NIHasWbx53QbjnqdsCIQCtM5ZG3PyV5SSN1grsNDqAP5G2cqLhMZ6ClwoZaJ8Y0wIhAI2CzXfvDTp3tZfYiEUydq9cJrexzomzC0q5cloOwPIHAiBlvs9B06Gh4JknpRyHg2r2WeGcXx1l0sM+DcJGCNqlNwIhALRnIYsWwtzVldRadRhlQ0MkznGR90KksfI5RRkVS+Yw";
            return SecurityCoderUtil.decryptRSAPrivate(cryptData, privateKey);
        }
        catch (Exception e) {
            throw new RuntimeException("解密错误，错误信息：", e);
        }
    }
    
    public static final String longToHex(final Long data) {
        return Long.toHexString(data);
    }
    
    public static final Long hexToLong(final String hex) {
        return Long.valueOf(hex, 16);
    }
    
    public static void main(final String[] args) throws Exception {
        final Long a = Long.MAX_VALUE;
        System.out.println(Long.MAX_VALUE);
        System.out.println(longToHex(a).toUpperCase());
        System.out.println(hexToLong(longToHex(a).toUpperCase()));
    }
}
